<html><head><title>CS334: Windows Programming</title></head><body>
        <center><h3>CS334 - Program 1: Loading Controls Dynamically
                <br>
                20 points
                <br>
                Due Date: Thursday, Feb 1, 2007 by 11:00 PM
            </h3>
        </center>
        <h4>Program Description
        </h4>
        The program has two forms, frmCreate and frmShow, and one code module.
        <ol>
            <li>
                (3 points) Code Module
                <ul>
                    <li>
                    The code module must define a sub main(), which will be the startup object. </li>
                    <li>
                    The module should define a SortedList, which will be used to store buttons 
                    created by the program. </li>
                    <li>
                    The module should also define a variable maxButtons for the maximal number of 
                    buttons that can be created by the program. The initial value of maxButtons is 
                    4.  </li>
                    <li> You can and should define some other variables. </li>
                </ul>
            </li><li>
                (8 points) Form frmCreate is used to create and remove command buttons.
                <ul>
                    <li>
                         Your form should be very similar to that in the sample program.
                        <ul>
                            <li>
                            At the beginning the form is displayed in the center of the screen.
                            </li><li>
                            The title is "Program 1" followed by your names.
                            </li><li>
                            The size of the form is (520, 360).
                            </li><li>
                            It has no controlbox.
                            </li><li>
                                The form has two menus (<u>F</u>ile and <u>B</u>utton), two textboxes 
                            (txtKey and txtCaption), and two labels.
                            </li><li>
                            The two textboxes have text "First" and "10" respectively at the beginning. The 
                            textboxes should be horizontally centered on the form.
                            </li><li>
                            The two labels have text "Button Caption" and "Button Key" respectively, and 
                            should be aligned with the textboxes on the left.
                            </li><li>
                                The form should have a textbox txtLimit to display the value of maxButtons and 
                                a button cmdSetLimit to set maxButtons.</li>
                            <li> The Tab order should be txtCaption, txtKey, txtLimit, cmdSetLimit. </li>
                        </ul>
                    </li><li>
                         The value of maxButtons shall be an integer and between 3 and 5. 
                         Clicking cmdSetLimit will set the value of maxButtons to that in txtLimit. 
                         <ul>
                         <li> If txtLimit 
                        does not represent an integer (including cases such as "2e3"), a messagebox
                        will be displayed; if the value of txtLimit is less than 3 or 
                        greater than 5, another messagebox will be displayed. In both cases, 
                        the value of maxButtons 
                        will remain unchanged and the value will be re-displayed in txtLimit. </li>
                        <li> If the new limit is valid, it will be assigned to maxButtons and displayed in txtLimit. </li>
                        <li> If the new valid limit is less than 
                        the number of buttons created already, all buttons will remain in the 
                        sortedList and on frmShow until removed. But new buttons cannot be created 
                        until the number of buttons is less than the new limit.</li>
                         </ul>
                    </li>
                    <li>
                         Menu <u>F</u>ile has two menu items: <u>S</u>HOW and E<u>X</u>IT. 
                        There is a separate bar between the two menu items. Clicking <u>S</u>HOW will 
                        display frmShow; clicking E<u>X</u>IT will terminate the program.
                    </li><li>
                        Menu <u>B</u>utton has two menu items: <u>C</u>REATE and <u>R</u>EMOVE.
                        <ul>
                            <li>
                                 Clicking <u>C</u>REATE will create a new command button that will be 
                                stored in the SortedList and also displayed on frmShow. The two boxes provide 
                                the key and the caption for the new button. All buttons should have a size of 
                                (75, 23). While a key is required in order to store the button in the 
                                SortedList, caption could be a null string. At most <i>maxButtons</i>
                            buttons can be created, and two buttons cannot have the same key. When any 
                            condition is violated, a message box should be displayed and no button will be 
                            created.
                            </li><li>
                                 Clicking <u>R</u>EMOVE will remove the button with the key 
                            specified in txtKey from both the SortedList and frmShow. A message box will be 
                            displayed when no key is specified or no button has the specified key.
                        </li></ul>
                            </li><li>
                            Each menu item should have a shortcut key and an access key as specified in the 
                            sample program.
                </li></ul>
            </li><li>
                (9 points) Form frmShow is used to display the created buttons.
                <ul>
                    <li>
                         Your form should be very similar to that in the sample program.
                        <ul>
                            <li>
                            The form should be displayed in the center of the screen.
                            </li><li>
                            Its title is "Program 1" followed by your names.
                            </li><li>
                            The form has no controlbox.
                            </li><li>
                            Its size is (650, 360) and the minimum size is (575, 70).
                            </li><li>
                                It has one menu <u>F</u>ile with two menu items: <u>B</u>ACK and E<u>X</u>IT. 
                                There is a separate bar between the two menu items. Clicking <u>B</u>ACK will 
                                hide frmShow and display frmCreate, clicking E<u>X</u>IT will terminate the 
                            program.
                        </li></ul>
                    </li><li>
                        Within the client size of frmShow, a margin of 100 is reserved on 
                        the left side and the right side, and the margins must be excluded when 
                        displaying buttons on the form. At any time, especially after a button is added 
                        or removed, the buttons should be displayed on frmShow as specified in the 
                        following:
                        <ul>
                            <li>
                            Vertically, each button is centered in the client area of the form, excluding the menu area.
                            </li><li>
                            Horizontally, the distances between them should be the same. The distance 
                            between the right side of the left margin and the left side of the first button 
                            from left should be the same as the distance between the buttons. The same 
                            requirement applies to the right margin.
                            </li><li>
                            All buttons should be displayed in ascending order of their keys as strings 
                            from left to right.
                        </li></ul>
                    </li><li> When the form is resized, the buttons must be arranged according to the above requirements. </li>
                    <li>
                     A shortcut menu will be displayed when right clicking anywhere on 
                    frmShow. The menu has three menu items: Font Bold, Font Italic, and Font 
                    Underline. Each menu item should have a shortcut key 
                    and an access key as specified in the sample program. </li>
                    <li> When none of the menu items is checked, the caption of all buttons 
                    will have a regular font style. Checking and unchecking any menu item will change the 
                    font style of all buttons accordingly. </li>
                    <li> When a new button is created, its font style is also 
                    determined by the three menu items. </li>
                    <li>
                     Clicking any button on frmShow will display a message box with the 
                    key and the caption of the button on two lines.
                    </li><li>
                        The following sub on frmShow is required. You will lose two points if it is 
                        missing. The sub should be called to display the buttons on the form.
                        <pre>      ' The sub displays all buttons on the form as required.
      Friend Sub ArrangeButtons()
</pre>
                </li></ul>
            </li><li>
                Bonus Points: You will receive 2 bonus points if you can change the font style 
                without using any if statement or select-case statement.
            </li>
            <li>
                Bonus Points: You will receive 2 bonus points if your sub ArrangeButtons has at most 12 lines
                (without calling any user-defined procedures).
            </li>
        </ol>
        
        <h4>Submission        </h4>
        <ul>
            <li> You <b>must</b> do the program in pairs. You must also sign a pairing sheet,
               and one student of each pair will be designated as the submitter. </li>
            <li>
            Drop your entire solution folder to folder Prog1 of the class DROP folder by 11 PM 
            Thursday, Feb 1. </li>
            <li>
                The name of the folder MUST be UserName, where UserName is the
            UWP UserName of the submitter of your pair.            </li>
            <li> You must send an email to the instructor with a brief peer evaluation of your partner
                 by 9 AM, Friday, Feb 2. </li>
            <li> You may lose up to two points for incorrect submission, including incorrect folder name. </li>
            <li> You must follow the programming rules, and you may lose up to 2 points on style.
</li>
         </ul>

    </body></html>